﻿Option Strict On
Option Explicit On
Friend Class NoScrollPanel
    Inherits Panel

    Protected Overrides Sub OnMouseWheel(ByVal e As MouseEventArgs)
        Dim mouseEvent As HandledMouseEventArgs = DirectCast(e, HandledMouseEventArgs)
        mouseEvent.Handled = True


        If e.Delta <> 0 Then
            'If e.Delta <= 0 Then
            '    If Form1.Fondo_PictureBox.Width < 500 Then Exit Sub 'minimum 500?
            'Else
            '    If Form1.Fondo_PictureBox.Width > 4000 Then Exit Sub 'maximum 2000?
            'End If

            For i = 0 To Me.Controls.Count - 1
                'Me.Controls(i).Width += CInt(Me.Controls(i).Width * e.Delta / 1000)
                'Me.Controls(i).Height += CInt(Me.Controls(i).Height * e.Delta / 1000)

                For j = 0 To Me.Controls(i).Controls.Count - 1
                    
                    Me.Controls(i).Controls(j).Width += CInt(Me.Controls(i).Controls(j).Width * e.Delta / 1000)
                    Me.Controls(i).Controls(j).Height += CInt(Me.Controls(i).Controls(j).Height * e.Delta / 1000)

                Next
            Next
            
            'Form1.Panel1.AutoScrollPosition = New Point(Form1.Panel1.AutoScrollPosition.X - e.Delta, Form1.Panel1.AutoScrollPosition.Y - e.Delta)

        End If

        

        
    End Sub
End Class
